
import java.io.*;


public class Assurance implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -6128527866986802536L;
	public static final int TYPE_CUSTOMER_SERVICE=0;
	public static final int TYPE_INDEPENDENT_ORGANIZATION=1;
	public static final int TYPE_COURT=2;
	public static final int TYPE_APPLICABLE_LAW=4;
	
	//general
	String name;
	String url;
	int type;
	String description;
	//remedies
	boolean errorCorrected;
	boolean lawSpecifies;
	boolean monetaryPaid;
	//image
	//???
	public Assurance(){
		name="";
		url="";
		type=0;
		description="";
		errorCorrected=false;
		lawSpecifies=false;
		monetaryPaid=false;
	}
	
	public Assurance(String n,String u,int t, String d, boolean e,boolean l,boolean m){
		name=n;
		url=u;
		type=t;
		description=d;
		errorCorrected=e;
		lawSpecifies=l;
		monetaryPaid=m;
	}
	
	public Assurance(Assurance a){
		name=a.name;
		url=a.url;
		type=a.type;
		description=a.description;
		errorCorrected=a.errorCorrected;
		lawSpecifies=a.lawSpecifies;
		monetaryPaid=a.monetaryPaid;
	}
	
	public String toXml(){
		//is called when constructing xml policy
		String ret="";
		String tp="";
		switch(type){
			case TYPE_CUSTOMER_SERVICE:
				tp="\"service\"";
				break;
			case TYPE_INDEPENDENT_ORGANIZATION:
				tp="\"independent\"";
				break;
			case TYPE_COURT:
				tp="\"court\"";
				break;
			case TYPE_APPLICABLE_LAW:
				tp="\"law\"";
				break;
			default:
					break;
		}
		ret=ret+"    <DISPUTES resolution-type="+tp;
			
		//if(!url.equals("")){
			//add url
			if(url.length()<7||!url.substring(0,7).equals("http://")){
				url="http://"+url;
			}
			ret=ret+" service=\""+url+"\"";
		//}		
		ret=ret+ " short-description=\""+name+"\">\n";
		ret=ret+"      <LONG-DESCRIPTION>"+description+"</LONG-DESCRIPTION>\n";
		if(!(errorCorrected||lawSpecifies||monetaryPaid)){
			ret=ret+"  <!-- No remedies specified -->\n";
		}else{
			ret=ret+"      <REMEDIES>";
			if(errorCorrected)
				ret=ret+"<correct/>";
			if(lawSpecifies)
				ret=ret+"<law/>";
			if(monetaryPaid)
				ret=ret+"<money/>";
			ret=ret+"</REMEDIES>\n";
		}
		ret=ret+"    </DISPUTES>\n";
		return ret;
	}

	public String toString(){
		return name;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public boolean isErrorCorrected() {
		return errorCorrected;
	}

	public void setErrorCorrected(boolean errorCorrected) {
		this.errorCorrected = errorCorrected;
	}

	public boolean isLawSpecifies() {
		return lawSpecifies;
	}

	public void setLawSpecifies(boolean lawSpecifies) {
		this.lawSpecifies = lawSpecifies;
	}

	public boolean isMonetaryPaid() {
		return monetaryPaid;
	}

	public void setMonetaryPaid(boolean monetaryPaid) {
		this.monetaryPaid = monetaryPaid;
	}
}
